

<!DOCTYPE html>
<html lang="zh-CN" data-default-color-scheme=auto>



<head>
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="/img/favicon.png">
  <link rel="icon" href="/img/favicon.png">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
  <meta name="theme-color" content="#2f4154">
  <meta name="author" content="Fly542">
  <meta name="keywords" content="">
  
    <meta name="description" content="bind9部分源码分析，基于bind9.18.21版源码 udp 启动监听过程1234567891011121314151617181920main			bin&#x2F;named&#x2F;main.c   进程入口函数	setup		bin&#x2F;named&#x2F;main.c   进程入口函数		named_log_init 	bin&#x2F;named&#x2F;log.c 日志初始化		create_managers  		bin&#x2F;n">
<meta property="og:type" content="article">
<meta property="og:title" content="DNS bind9 源码分析">
<meta property="og:url" content="http://fly542.cn/2024/05/13/03%E8%BD%AF%E4%BB%B6%E5%BC%80%E5%8F%91/07%E5%BA%94%E7%94%A8%E8%BD%AF%E4%BB%B6/DNS%20bind9%20%E6%BA%90%E7%A0%81%E5%88%86%E6%9E%90/index.html">
<meta property="og:site_name" content="Fly542 技术沉淀">
<meta property="og:description" content="bind9部分源码分析，基于bind9.18.21版源码 udp 启动监听过程1234567891011121314151617181920main			bin&#x2F;named&#x2F;main.c   进程入口函数	setup		bin&#x2F;named&#x2F;main.c   进程入口函数		named_log_init 	bin&#x2F;named&#x2F;log.c 日志初始化		create_managers  		bin&#x2F;n">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2024-05-13T07:26:04.000Z">
<meta property="article:modified_time" content="2025-09-26T05:34:52.475Z">
<meta property="article:author" content="Fly542">
<meta property="article:tag" content="dns">
<meta property="article:tag" content="bind">
<meta name="twitter:card" content="summary_large_image">
  
  
  <title>DNS bind9 源码分析 - Fly542 技术沉淀</title>

  <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4/dist/css/bootstrap.min.css" />


  <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/github-markdown-css@4/github-markdown.min.css" />
  <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/hint.css@2/hint.min.css" />

  
    
    
      
      <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/highlight.js@10/styles/github-gist.min.css" />
    
  

  
    <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3/dist/jquery.fancybox.min.css" />
  


<!-- 主题依赖的图标库，不要自行修改 -->

<link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_ba1fz6golrf.css">



<link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_lbnruvf0jn.css">


<link  rel="stylesheet" href="/css/main.css" />

<!-- 自定义样式保持在最底部 -->


  <script id="fluid-configs">
    var Fluid = window.Fluid || {};
    var CONFIG = {"hostname":"fly542.cn","root":"/","version":"1.8.14","typing":{"enable":true,"typeSpeed":70,"cursorChar":"_","loop":false},"anchorjs":{"enable":true,"element":"h1,h2,h3,h4,h5,h6","placement":"right","visible":"hover","icon":""},"progressbar":{"enable":true,"height_px":3,"color":"#29d","options":{"showSpinner":false,"trickleSpeed":100}},"copy_btn":true,"image_zoom":{"enable":true,"img_url_replace":["",""]},"toc":{"enable":true,"headingSelector":"h1,h2,h3,h4,h5,h6","collapseDepth":0},"lazyload":{"enable":true,"loading_img":"/img/loading.gif","onlypost":false,"offset_factor":2},"web_analytics":{"enable":false,"baidu":null,"google":null,"gtag":null,"tencent":{"sid":null,"cid":null},"woyaola":null,"cnzz":null,"leancloud":{"app_id":null,"app_key":null,"server_url":null,"path":"window.location.pathname","ignore_local":false}},"search_path":"/local-search.xml"};
  </script>
  <script  src="/js/utils.js" ></script>
  <script  src="/js/color-schema.js" ></script>
<meta name="generator" content="Hexo 6.0.0"></head>


<body>
  <header style="height: 70vh;">
    <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand" href="/">
      <strong>Fly542 技术沉淀</strong>
    </a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/">
                <i class="iconfont icon-home-fill"></i>
                首页
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/archives/">
                <i class="iconfont icon-archive-fill"></i>
                归档
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/categories/">
                <i class="iconfont icon-category-fill"></i>
                分类
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/tags/">
                <i class="iconfont icon-tags-fill"></i>
                标签
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/about/">
                <i class="iconfont icon-user-fill"></i>
                关于
              </a>
            </li>
          
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" target="_self" href="javascript:;" data-toggle="modal" data-target="#modalSearch" aria-label="Search">
              &nbsp;<i class="iconfont icon-search"></i>&nbsp;
            </a>
          </li>
        
        
          <li class="nav-item" id="color-toggle-btn">
            <a class="nav-link" target="_self" href="javascript:;" aria-label="Color Toggle">&nbsp;<i
                class="iconfont icon-dark" id="color-toggle-icon"></i>&nbsp;</a>
          </li>
        
      </ul>
    </div>
  </div>
</nav>

    <div class="banner" id="banner" parallax=true
         style="background: url('/img/default.png') no-repeat center center;
           background-size: cover;">
      <div class="full-bg-img">
        <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
          <div class="page-header text-center fade-in-up">
            <span class="h2" id="subtitle" title="DNS bind9 源码分析">
              
            </span>

            
              <div class="mt-3">
  
  
    <span class="post-meta">
      <i class="iconfont icon-date-fill" aria-hidden="true"></i>
      <time datetime="2024-05-13 15:26" pubdate>
        2024年5月13日 下午
      </time>
    </span>
  
</div>

<div class="mt-1">
  
    <span class="post-meta mr-2">
      <i class="iconfont icon-chart"></i>
      4.6k 字
    </span>
  

  
    <span class="post-meta mr-2">
      <i class="iconfont icon-clock-fill"></i>
      
      
      39 分钟
    </span>
  

  
  
</div>

            
          </div>

          
        </div>
      </div>
    </div>
  </header>

  <main>
    
      

<div class="container-fluid nopadding-x">
  <div class="row nomargin-x">
    <div class="d-none d-lg-block col-lg-2"></div>
    <div class="col-lg-8 nopadding-x-md">
      <div class="container nopadding-x-md" id="board-ctn">
        <div class="py-5" id="board">
          <article class="post-content mx-auto">
            <!-- SEO header -->
            <h1 style="display: none">DNS bind9 源码分析</h1>
            
            <div class="markdown-body">
              <p>bind9部分源码分析，基于<a target="_blank" rel="noopener" href="https://github.com/isc-projects/bind9/archive/refs/tags/v9.18.21.tar.gz">bind9.18.21版源码</a></p>
<h1 id="udp-启动监听过程"><a href="#udp-启动监听过程" class="headerlink" title="udp 启动监听过程"></a>udp 启动监听过程</h1><figure class="highlight awk"><table><tr><td class="gutter"><div class="code-wrapper"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></div></td><td class="code"><pre><code class="hljs awk">main			bin<span class="hljs-regexp">/named/m</span>ain.c   进程入口函数<br>	setup		bin<span class="hljs-regexp">/named/m</span>ain.c   进程入口函数<br>		named_log_init 	bin<span class="hljs-regexp">/named/</span>log.c 日志初始化<br>		create_managers  		bin<span class="hljs-regexp">/named/m</span>ain.c   创建各种管理对象<br>		named_server_create  	bin<span class="hljs-regexp">/named/</span>server.c 服务端创建<br>			ns_server_create 	lib<span class="hljs-regexp">/ns/</span>server.c 	创建ns server<br>			run_server 			bin<span class="hljs-regexp">/named/</span>server.c<br>				load_configuration      <span class="hljs-regexp">//</span> 加载配置  ，成功后日志才能生效 bin<span class="hljs-regexp">/named/</span>server.c<br>					ns_interfacemgr_scan   <span class="hljs-regexp">//</span> lib<span class="hljs-regexp">/ns/i</span>nterfacemgr.c   扫描本地网卡<br>						do_scan 		lib<span class="hljs-regexp">/ns/i</span>nterfacemgr.c<br>							interface_setup	lib<span class="hljs-regexp">/ns/i</span>nterfacemgr.c<br>								ns_interface_listenhttp			<span class="hljs-regexp">//</span> 建立http监听 <br>								ns_interface_listentls			<span class="hljs-regexp">//</span> 建立tsl监听<br>								ns_interface_listenudp			<span class="hljs-regexp">//</span> 建立udp监听,，指定连接回调函数为 ns__client_request，  lib<span class="hljs-regexp">/ns/i</span>nterfacemgr.c<br>									isc_nm_listenudp 			<span class="hljs-regexp">//</span> 建立udp监听 lib<span class="hljs-regexp">/isc/</span>netmgr/udp.c  <br>										start_udp_child			<span class="hljs-regexp">//</span> 设置udp连接回调函数<br>											isc__nm_udp_lb_socket	<span class="hljs-regexp">//</span> 调用<br>												isc__nm_socket		<span class="hljs-regexp">//</span> 调用socket函数创建监听 <span class="hljs-regexp">//</span> lib<span class="hljs-regexp">/isc/</span>netmgr/netmgr.c<br>								ns_interface_listentcp			<span class="hljs-regexp">//</span> 建立udp监听,						<br>				load_zones				<span class="hljs-regexp">//</span> 加载zones ，成功后日志才能生效 bin<span class="hljs-regexp">/named/</span>server.c<br></code></pre></td></tr></table></figure>

<h1 id="udp事件循环处理过程"><a href="#udp事件循环处理过程" class="headerlink" title="udp事件循环处理过程"></a>udp事件循环处理过程</h1><figure class="highlight xl"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><code class="hljs xl">create_managers	<span class="hljs-comment">// 创建各种管理对象 bind/bin/named/main.c</span><br>	isc_managers_create <span class="hljs-comment">// 创建管理对象  lib/isc/managers.c</span><br>		isc__netmgr_create			<span class="hljs-comment">// 创建网络管理对象 初始化libuv使用对象， 并传递nm_thread为线程的启动入口函数，在nm_thread中执行libuv的uv_run循环函数 lib/isc/netmgr/netmgr.c</span><br>			isc_thread_create		<span class="hljs-comment">// 创建线程 ./lib/isc/thread.c </span><br>				isc__trampoline_run	<span class="hljs-comment">// ./lib/isc/trampoline.c   ./lib/isc/netmgr/netmgr.c  //绑定到libuv  uv_queue_work</span><br>					<span class="hljs-function"><span class="hljs-title">result</span> = (trampoline-&gt;</span><span class="hljs-function"><span class="hljs-title">start</span>)(trampoline-&gt;</span>arg);  <span class="hljs-comment">//启动线程主运行函数</span><br>					<br>	<br>isc__nmsocket_timer_restart          <span class="hljs-comment">//  lib/isc/netmgr/netmgr.c</span><br>	isc__nmsocket_readtimeout_cb    <span class="hljs-comment">// 网络管理器的读超时回调函数  lib/isc/netmgr/netmgr.c</span><br>		isc__nm_readcb		<span class="hljs-comment">// lib/isc/netmgr/netmgr.c</span><br>			isc__nm_async_readcb<br>				<span class="hljs-function"><span class="hljs-title">uvreq</span>-&gt;</span><span class="hljs-function"><span class="hljs-title">cb</span>.recv(uvreq-&gt;</span><span class="hljs-function"><span class="hljs-title">handle</span>, eresult, &amp;region, uvreq-&gt;</span>cbarg); <span class="hljs-comment">// 回调到 ns__client_request</span><br></code></pre></td></tr></table></figure>

<h1 id="udp请求处理过程"><a href="#udp请求处理过程" class="headerlink" title="udp请求处理过程"></a>udp请求处理过程</h1><figure class="highlight awk"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><code class="hljs awk">ns__client_request 			<span class="hljs-regexp">//</span> 接收到的udp消息处理入口函数 .<span class="hljs-regexp">/lib/</span>ns/client.c <br>	result = client-&gt;sctx-&gt;matchingview(); <span class="hljs-regexp">//</span> 查询view,实际指向bind<span class="hljs-regexp">/bin/</span>named/server.c 的 get_matching_view<br>        dns_acl_allowed         <span class="hljs-regexp">//</span> lib<span class="hljs-regexp">/dns/</span>acl.c get_matching_view查询acl<br>            dns_acl_match       <span class="hljs-regexp">//</span> lib<span class="hljs-regexp">/dns/</span>acl.c<br>	ns_query_start			<span class="hljs-regexp">//</span> 处理查询消息 .<span class="hljs-regexp">/lib/</span>ns/query.c<br>		query_setup<br>			ns__query_start<br></code></pre></td></tr></table></figure>

<h1 id="zone加载过程"><a href="#zone加载过程" class="headerlink" title="zone加载过程"></a>zone加载过程</h1><figure class="highlight awk"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><code class="hljs awk">run_server	<span class="hljs-regexp">//</span> 加载zones ， bin<span class="hljs-regexp">/named/</span>server.c<br>	load_configuration<br>		cfg_parse_file(conf_parser, filename, &amp;cfg_type_namedconf,&amp;config)		<span class="hljs-regexp">//</span> 解析named文件 bin<span class="hljs-regexp">/named/</span>server.c, conf_parser-&gt;lexer-&gt;sources 存放各个打开的文件对象, sources[i].name = filename; sources[i].input 为打开的FILE流对象<br>			parse2			<span class="hljs-regexp">//</span> lib<span class="hljs-regexp">/isccfg/</span>parser.c<br>				cfg_parse_obj <span class="hljs-regexp">//</span> lib<span class="hljs-regexp">/isccfg/</span>parser.c, result = type-&gt;parse(pctx, type, ret);type实际是 cfg_type_namedconf parse实际回调到cfg_parse_mapbody  <br>					cfg_parse_mapbody   <span class="hljs-regexp">//</span> lib<span class="hljs-regexp">/isccfg/</span>parser.c,  <span class="hljs-regexp">//</span> 通过redo 和 parser_openfile 来循环打开各个include文件，并解析相关关键字<br>						CHECK(cfg_parse_listelt(pctx, clause-&gt;type, &amp;elt));  <span class="hljs-regexp">//</span> 调用此语句循环解析<br>							cfg_parse_obj 解析<br>	load_zones	<span class="hljs-regexp">//</span> 循环加载所有的 zones  bin<span class="hljs-regexp">/named/</span>server.c<br>		dns_zone_load		<span class="hljs-regexp">//</span> lib<span class="hljs-regexp">/dns/</span>zone.c<br>			zone_load		<span class="hljs-regexp">//</span> lib<span class="hljs-regexp">/dns/</span>zone.c<br></code></pre></td></tr></table></figure>

<h1 id="acl"><a href="#acl" class="headerlink" title="acl"></a>acl</h1><p>关键变量指向</p>
<figure class="highlight xl"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><code class="hljs xl"><span class="hljs-function"><span class="hljs-title">cfg_type_namedconf</span>-&gt;</span><span class="hljs-function"><span class="hljs-title">of</span>----&gt;</span>指向 变量 namedconf_clausesets <br>	<span class="hljs-function"><span class="hljs-title">namedconf_clausesets</span>[0]-&gt;</span><span class="hljs-function"><span class="hljs-title">type</span>---&gt;</span>指向 变量 namedconf_clauses，<br>		<span class="hljs-function"><span class="hljs-title">namedconf_clauses</span>[0]-&gt;</span><span class="hljs-function"><span class="hljs-title">type</span>---&gt;</span>指向 变量 cfg_type_acl 用于解析acl模块<br>			<span class="hljs-function"><span class="hljs-title">cfg_type_acl</span>-&gt;</span>type 指向 cfg_parse_tuple 解析acl后面的内容<br>			<span class="hljs-function"><span class="hljs-title">cfg_type_acl</span>-&gt;</span>of[<span class="hljs-number">0</span>]指向acl_fields[<span class="hljs-number">0</span>] 存储acl的<span class="hljs-keyword">name</span><br>			<span class="hljs-function"><span class="hljs-title">cfg_type_acl</span>-&gt;</span>of[<span class="hljs-number">1</span>]指向acl_fields[<span class="hljs-number">1</span>] 存储acl的地址列表, acl_fields[<span class="hljs-number">1</span>].type指向 cfg_type_bracketed_aml<br>				<span class="hljs-function"><span class="hljs-title">cfg_type_bracketed_aml</span>-&gt;</span>type指向 cfg_parse_bracketed_list <span class="hljs-comment">// 用于解析地址列表</span><br>					cfg_parse_bracketed_list    <span class="hljs-comment">//  parser.c: 解析acl 地址列表块</span><br>						parse_list  			<span class="hljs-comment">//  parser.c: 循环解析&#123;&#125;中的所有地址列表</span><br>							cfg_peektoken       <span class="hljs-comment">// parser.c: 每次解析一个token</span><br>								cfg_gettoken    <span class="hljs-comment">// parser.c: 获取一个token</span><br>							<br>	<span class="hljs-function"><span class="hljs-title">namedconf_clausesets</span>[1]---&gt;</span>指向 namedconf_or_view_clauses    <span class="hljs-comment">// clause 指是一个由选项名和对应值组成且以分号结尾的的语句块(block)</span><br>namedconf_clauses 中定义了 named.conf文件的顶层字段处理函数<br><br>namedconf.c中的cfg_type_acl定义acl标记解析函数<br></code></pre></td></tr></table></figure>

<p>解析调用</p>
<figure class="highlight awk"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><code class="hljs awk">load_configuration	 	<span class="hljs-regexp">//</span> bin<span class="hljs-regexp">/named/</span>server.c<br>	bind9_check_namedconf	<span class="hljs-regexp">//</span> lib<span class="hljs-regexp">/bind9/</span>check.c<br>		check_viewconf<br>			checkacl<br>				cfg_acl_fromconfig<br>					cfg_acl_fromconfig2<br>						count_acl_elements<br>							get_acl_def<br></code></pre></td></tr></table></figure>

<h1 id="recursion-与-forward"><a href="#recursion-与-forward" class="headerlink" title="recursion 与 forward"></a>recursion 与 forward</h1><p>fctx_ 开头为fetch context的缩写，获取结果的上下文;resquery_t 为resolver query 的缩写.</p>
<ol>
<li><p>客户端发起递归:</p>
<figure class="highlight awk"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><code class="hljs awk"><br>ns_query_recurse       ns/query.c   递归或forward查询的入口函数<br>	dns_resolver_createfetch   lib<span class="hljs-regexp">/dns/</span>resolver.c 创建递归任务,设置回调函数 fetch_callback<br>		<br>	返回并异步等待 fetch_callback 回调<br></code></pre></td></tr></table></figure></li>
<li><p>创建递归任务并执行:</p>
<figure class="highlight awk"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><code class="hljs awk">dns_resolver_createfetch   <span class="hljs-regexp">//</span> lib<span class="hljs-regexp">/dns/</span>resolver.c 创建递归任务<br>	fctx_create            <span class="hljs-regexp">//</span> lib<span class="hljs-regexp">/dns/</span>resolver.c 创建 fetchctx_t 对象<br>	fctx_join              <span class="hljs-regexp">//</span> lib<span class="hljs-regexp">/dns/</span>resolver.c 添加回调fetch_callback事件<br>	ISC_EVENT_INIT         <span class="hljs-regexp">//</span> 初始化event,并设置事件执行函数为 fctx_start，参数为fctx<br>	isc_task_send          <span class="hljs-regexp">//</span> 加入事件到队列等待执行	<br></code></pre></td></tr></table></figure></li>
<li><p>任务执行</p>
<figure class="highlight awk"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><code class="hljs awk">fctx_start<br>	fctx_try<br>		fctx_query<br>			dns_dispatch_add   <span class="hljs-regexp">//</span> 设置递归发送函数 resquery_connected， 应答函数 resquery_response<br></code></pre></td></tr></table></figure></li>
<li><p>发送请求</p>
<figure class="highlight awk"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><code class="hljs awk">udp_connected        dispatch.c<br>	resquery_connected    resolver.c   <br>		resquery_send     resolver.c   <span class="hljs-regexp">//</span> 发送forward请求<br>			fctx_addopt                <span class="hljs-regexp">//</span> 添加ecs数据<br>			dns_dispatch_send          <span class="hljs-regexp">//</span> 发送<br></code></pre></td></tr></table></figure></li>
</ol>
<h1 id="日志格式说明"><a href="#日志格式说明" class="headerlink" title="日志格式说明"></a>日志格式说明</h1><p>13-May-2024 08:48:58.790 client @0x7f2638382ce8 127.0.0.1#50272 (oa.xxx.domain): view view_default: query: oa.xxx.domain IN A +E(0)K (127.0.0.1) [ECS 10.1.102.1/32/0]</p>
<p>+/- 递归/非递归<br>E(0) 0 代表edns版本号</p>
<h1 id="其他"><a href="#其他" class="headerlink" title="其他"></a>其他</h1><ul>
<li><p>include/dns/enumclass.h include/dns/enumtype.h include/dns/rdatastruct.h include/dns/code.h 是通过Makefile生成的，Makefile调用 gen.c文件生成二进制程序gen，来生成相关头文件。 为什么这么做原因待确定</p>
</li>
<li><p>版本号由文件 <code>./configure</code> 中<code>PACKAGE_VERSION</code>和<code>PACKAGE_STRING</code>控制</p>
</li>
</ul>

            </div>
            <hr>
            <div>
              <div class="post-metas mb-3">
                
                  <div class="post-meta mr-3">
                    <i class="iconfont icon-category"></i>
                    
                      <a class="hover-with-bg" href="/categories/%E8%BD%AF%E4%BB%B6%E5%BC%80%E5%8F%91/">软件开发</a>
                    
                  </div>
                
                
                  <div class="post-meta">
                    <i class="iconfont icon-tags"></i>
                    
                      <a class="hover-with-bg" href="/tags/dns/">dns</a>
                    
                      <a class="hover-with-bg" href="/tags/bind/">bind</a>
                    
                  </div>
                
              </div>
              
                <p class="note note-warning">
                  
                    本博客所有文章除特别声明外，均采用 <a target="_blank" href="https://creativecommons.org/licenses/by-sa/4.0/deed.zh" rel="nofollow noopener noopener">CC BY-SA 4.0 协议</a> ，转载请注明出处！
                  
                </p>
              
              
                <div class="post-prevnext">
                  <article class="post-prev col-6">
                    
                    
                      <a href="/2024/05/17/03%E8%BD%AF%E4%BB%B6%E5%BC%80%E5%8F%91/07%E5%BA%94%E7%94%A8%E8%BD%AF%E4%BB%B6/bind%E7%9B%B8%E5%85%B3%E6%A6%82%E5%BF%B5/">
                        <i class="iconfont icon-arrowleft"></i>
                        <span class="hidden-mobile">bind中view和zone的区别</span>
                        <span class="visible-mobile">上一篇</span>
                      </a>
                    
                  </article>
                  <article class="post-next col-6">
                    
                    
                      <a href="/2024/04/22/04DevOps/33grafana/">
                        <span class="hidden-mobile">Prometheus与Grafana</span>
                        <span class="visible-mobile">下一篇</span>
                        <i class="iconfont icon-arrowright"></i>
                      </a>
                    
                  </article>
                </div>
              
            </div>

            
          </article>
        </div>
      </div>
    </div>
    
      <div class="d-none d-lg-block col-lg-2 toc-container" id="toc-ctn">
        <div id="toc">
  <p class="toc-header"><i class="iconfont icon-list"></i>&nbsp;目录</p>
  <div class="toc-body" id="toc-body"></div>
</div>

      </div>
    
  </div>
</div>

<!-- Custom -->


    

    
      <a id="scroll-top-button" aria-label="TOP" href="#" role="button">
        <i class="iconfont icon-arrowup" aria-hidden="true"></i>
      </a>
    

    
      <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
     aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">搜索</h4>
        <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input type="text" id="local-search-input" class="form-control validate">
          <label data-error="x" data-success="v"
                 for="local-search-input">关键词</label>
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>
    

    
  </main>

  <footer class="text-center mt-5 py-3">
  <div class="footer-content">
     <a href="https://hexo.io" target="_blank" rel="nofollow noopener"><span>Hexo</span></a> <i class="iconfont icon-love"></i> <a href="https://github.com/fluid-dev/hexo-theme-fluid" target="_blank" rel="nofollow noopener"><span>Fluid</span></a> 
  </div>
  

  

  
</footer>


  <!-- SCRIPTS -->
  
  <script  src="https://cdn.jsdelivr.net/npm/nprogress@0/nprogress.min.js" ></script>
  <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/nprogress@0/nprogress.min.css" />

  <script>
    NProgress.configure({"showSpinner":false,"trickleSpeed":100})
    NProgress.start()
    window.addEventListener('load', function() {
      NProgress.done();
    })
  </script>


<script  src="https://cdn.jsdelivr.net/npm/jquery@3/dist/jquery.min.js" ></script>
<script  src="https://cdn.jsdelivr.net/npm/bootstrap@4/dist/js/bootstrap.min.js" ></script>
<script  src="/js/events.js" ></script>
<script  src="/js/plugins.js" ></script>

<!-- Plugins -->


  <script  src="/js/local-search.js" ></script>



  
    <script  src="/js/img-lazyload.js" ></script>
  



  



  
    <script  src="https://cdn.jsdelivr.net/npm/tocbot@4/dist/tocbot.min.js" ></script>
  
  
    <script  src="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3/dist/jquery.fancybox.min.js" ></script>
  
  
    <script  src="https://cdn.jsdelivr.net/npm/anchor-js@4/anchor.min.js" ></script>
  
  
    <script defer src="https://cdn.jsdelivr.net/npm/clipboard@2/dist/clipboard.min.js" ></script>
  






  <script  src="https://cdn.jsdelivr.net/npm/typed.js@2/lib/typed.min.js" ></script>
  <script>
    (function (window, document) {
      var typing = Fluid.plugins.typing;
      var title = document.getElementById('subtitle').title;
      
        typing(title);
      
    })(window, document);
  </script>















<!-- 主题的启动项 保持在最底部 -->
<script  src="/js/boot.js" ></script>


</body>
</html>
